package com.gitee.xhs.window.evictors;

import com.gitee.xhs.sampleRecod.transactionRecord.Transaction;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.flink.streaming.runtime.operators.windowing.TimestampedValue;

/**
 * @author BigHead
 * @date 2022/7/27 10:43
 * @description CustomAfterEvictors
 * after执行后会在做state前执行
 * 涉及源码如下
 * @see org.apache.flink.streaming.runtime.operators.windowing.EvictingWindowOperator 405
 * evictorContext.evictAfter(recordsWithTimestamp, Iterables.size(recordsWithTimestamp));
 * 这里是源码，执行after之后在做windowState的时候减少state的数据
 */
public class CustomAfterEvictors extends AbstractCustomEvictors {

    CustomAfterEvictors() {
        super(2);
    }

    @Override
    public void evictBefore(Iterable<TimestampedValue<Transaction>> elements, int size, TimeWindow window, EvictorContext evictorContext) {

    }

    @Override
    public void evictAfter(Iterable<TimestampedValue<Transaction>> elements, int size, TimeWindow window, EvictorContext evictorContext) {
        removeElement(elements, size);
    }
}
